<!--
 * @Description: 商品列表(2021/07/07优化)
 * @Author: liyujie
 * @Date: 2021/7/7
 * @Last Modified by: liyujie
 * @Last Modified time: 2021/7/7
-->
<template>
    <section class="wrapper">
        <div class="content-wrapper">
            <!-- header -->
            <div class="header">
                <div class="header-title">
                    商品列表
                </div>
                <div class="opt-btn-group">
                    <div
                        class="opt-btn-item"
                        @click="handleRoute('noSettleGoodsList')"
                    >
                        无需结算商品
                    </div>
                    <div
                        class="opt-btn-item"
                        @click="handleRoute('goodsCollect')"
                    >
                        采集
                    </div>
                    <div
                        class="opt-btn-item"
                        @click="handleRoute('shopBrowse')"
                    >
                        销量自增长管理
                    </div>
                    <div
                        class="opt-btn-item"
                        @click="handleRoute('shopVolumnBrowse')"
                    >
                        浏览量自增长管理
                    </div>
                    <div
                        class="opt-btn-item"
                        @click="$refs.importTaoGoods.show()"
                    >
                        导入淘客商品
                    </div>
                </div>
            </div>
            <!-- /header -->
            <!-- 筛选-->
            <div class="filter-view">
                <div class="header-new-box">
                    <el-radio-group
                        v-model="filterData.goods_type"
                        size="small"
                        @change="getTableData(1)"
                    >
                        <el-radio-button
                            v-for="item in goodsTypeList"
                            :key="item.value"
                            :label="item.value"
                        >
                            {{ item.label }}
                        </el-radio-button>
                    </el-radio-group>
                </div>
                <div class="header-new-box">
                    <p class="header-new-box-title">商品名称</p>
                    <el-input
                        placeholder="商品名称"
                        v-model="filterData.goods_title"
                        suffix-icon="el-icon-search"
                        clearable
                        size="small"
                        @keydown.enter.native="getTableData(1)"
                    />
                </div>
                <div class="header-new-box">
                    <p class="header-new-box-title">店铺名称</p>
                    <el-input
                        placeholder="店铺名称"
                        v-model="filterData.shop_title"
                        suffix-icon="el-icon-search"
                        clearable
                        size="small"
                        @keydown.enter.native="getTableData(1)"
                    />
                </div>
                <div class="header-new-box">
                    <p class="header-new-box-title">商品分类</p>
                    <el-cascader
                        placeholder="请选择"
                        :options="typeList"
                        filterable
                        clearable
                        size="small"
                        change-on-select
                        expand-trigger="click"
                        v-model="filterData.selectedType"
                        :props="{
                            label: 'title',
                            value: 'no',
                            children: 'children'
                        }"
                        style="width: 100%"
                        @change="getTableData(1)"
                    />
                </div>
                <template v-if="!isFold">
                    <div class="header-new-box">
                        <p class="header-new-box-title">审核状态</p>
                        <el-select
                            clearable
                            class="filter-input"
                            v-model="filterData.audit_status"
                            filterable
                            size="small"
                            @change="getTableData(1)"
                            placeholder="请选择"
                        >
                            <el-option
                                v-for="item in verifyList"
                                :key="item.value"
                                :label="item.label"
                                :value="item.value"
                            />
                        </el-select>
                    </div>
                    <div class="header-new-box">
                        <p class="header-new-box-title">上架状态</p>
                        <el-select
                            clearable
                            class="filter-input"
                            v-model="filterData.goods_status"
                            filterable
                            size="small"
                            placeholder="请选择"
                            @change="getTableData(1)"
                        >
                            <el-option
                                v-for="item in statusList"
                                :key="item.value"
                                :label="item.label"
                                :value="item.value"
                            />
                        </el-select>
                    </div>
                    <div class="header-new-box">
                        <p class="header-new-box-title">淘客佣金</p>
                        <el-input
                            class="number-input-number"
                            clearable
                            v-model="filterData.commission_money_range"
                            :min="0"
                            style="width: 130px"
                            size="small"
                            type="number"
                        />
                        <span style="margin: 0 6px">-</span>
                        <el-input
                            class="number-input-number"
                            clearable
                            v-model="filterData.commission_money_rangeEnd"
                            :min="0"
                            style="width: 130px"
                            size="small"
                            type="number"
                        />
                    </div>
                    <div class="header-new-box">
                        <p class="header-new-box-title">商品组</p>
                        <el-select
                            v-model="filterData.cate_no_type"
                            filterable
                            clearable
                            size="small"
                            placeholder="请选择"
                            @change="getTableData(1)"
                        >
                            <el-option
                                v-for="item in typeAllListType"
                                :key="item.cate_no"
                                :label="item.cate_name"
                                :value="item.cate_no"
                            />
                        </el-select>
                    </div>
                    <div class="header-new-box">
                        <p class="header-new-box-title">商品组精选</p>
                        <el-select
                            v-model="filterData.set_cate_recommend"
                            placeholder="请选择"
                            size="small"
                            @change="fnSetCate"
                        >
                            <el-option
                                label="全部"
                                value=""
                            /><el-option
                                label="是"
                                :value="1"
                            /><el-option
                                label="否"
                                :value="0"
                            />
                        </el-select>
                    </div>
                    <div class="header-new-box">
                        <p class="header-new-box-title">销量自增长</p>
                        <el-select
                            v-model="volume"
                            placeholder="请选择"
                            size="small"
                            @change="getTableData(1)"
                        >
                            <el-option
                                v-for="item in optionList"
                                :key="item.value"
                                :label="item.label"
                                :value="item.value"
                            />
                        </el-select>
                    </div>
                    <div class="header-new-box">
                        <p class="header-new-box-title">浏览量增长</p>
                        <el-select
                            v-model="autoinc_view_set"
                            placeholder="请选择"
                            size="small"
                            @change="getTableData(1)"
                        >
                            <el-option
                                v-for="item in optionList"
                                :key="item.value"
                                :label="item.label"
                                :value="item.value"
                            />
                        </el-select>
                    </div>
                    <div class="header-new-box">
                        <p class="header-new-box-title">学校权限</p>
                        <el-select
                            v-model="school_filter_status"
                            placeholder="请选择"
                            size="small"
                            @change="getTableData(1)"
                        >
                            <el-option
                                v-for="item in optionList"
                                :key="item.value"
                                :label="item.label"
                                :value="item.value"
                            />
                        </el-select>
                    </div>
                </template>
                <div class="header-new-box">
                    <el-button
                        type="primary"
                        size="small"
                        @click="getTableData(1)"
                    >
                        搜索
                    </el-button>
                    <el-button
                        type="primary"
                        size="small"
                        @click="handleReset"
                    >
                        重置
                    </el-button>
                    <el-button
                        type="primary"
                        size="small"
                        @click="isFold = !isFold"
                    >
                        {{ isFold ? '展开' : '收起' }}
                        <i :class="isFold ? 'el-icon-arrow-down' : 'el-icon-arrow-up'"/>
                    </el-button>
                </div>
            </div>
            <!--筛选-->

            <!-- table -->
            <div
                class="table-wrapper"
                ref="tableWrapper"
            >
                <el-table
                    :data="tableData"
                    height="100%"
                    style="width: 100%;"
                    class="data-table"
                    v-loading="tableLoading"
                    ref="goodsTable"
                    @sort-change="handleSortChanged"
                    @select="fnSelect"
                    @select-all="fnSelectAllTop"
                    @selection-change="handleSelectionChange"
                >
                    <el-table-column
                        type="selection"
                        width="50"
                        align="center"
                        fixed="left"
                    />
                    <el-table-column
                        width="320"
                        label="商品信息"
                        fixed="left"
                    >
                        <template slot-scope="scope">
                            <div class="goods-info">
                                <img
                                    :src="scope.row.goods_cover"
                                    class="goods-cover"
                                    @click="fnShowPreview(scope.row.goods_cover)"
                                >
                                <div class="info">
                                    <div
                                        class="goods-info__title shop-item-jump"
                                        @click="fnGoShoplist(scope.row)"
                                    >
                                        {{ scope.row.goods_title }}
                                    </div>
                                    <div class="goods-info__no">
                                        商品编号：{{ scope.row.goods_no }}
                                    </div>
                                    <div class="goods-info__shop-title">
                                        店铺名称：{{ scope.row.shop_title }}
                                    </div>
                                </div>
                            </div>
                        </template>
                    </el-table-column>
                    <el-table-column
                        label="商品单价"
                        prop="goods_price"
                        width="110"
                        align="center"
                        sortable="custom"
                    >
                        <template slot-scope="scope">
                            <span v-if="Number(filterData.goods_type) !== 4 ">{{ scope.row.goods_price }}</span>
                            <span v-if="Number(filterData.goods_type) === 4 ">0</span>
                        </template>
                    </el-table-column>
                    <el-table-column
                        :formatter="emptyFormatter"
                        prop="goods_price_origin"
                        width="130"
                        label="淘宝售价"
                        align="center"
                        sortable="custom"
                        :render-header="(h, title, content) => renderHeader(h, '淘宝售价', '淘宝售价为当前该商品在淘宝上的在售价格')"
                    />
                    <el-table-column
                        :formatter="emptyFormatter"
                        prop="goods_commission"
                        label="佣金"
                        sortable="custom"
                    />
                    <el-table-column
                        label="优惠力度"
                        align="center"
                    >
                        <template slot-scope="scope">
                            <div class="cursor-font">
                                <el-popover
                                    placement="left"
                                    :width="scope.row.reduction_info.list.length == 0 ? 120 :'auto'"
                                >
                                    <div
                                        v-if="scope.row.reduction_info.list.length > 0"
                                        :style="{width: '100%', textAlign: 'center', display: 'flex', flexDirection: 'column'}"
                                    >
                                        <div :style="{height: '28px', display: scope.row.reduction_info.list.length > 1 ? 'flex' : '', alignItems: 'center'}">
                                            <div
                                                v-for="(item, index) in scope.row.reduction_info.list"
                                                :key="index"
                                            >
                                                <div
                                                    v-if="index <= 2"
                                                    class="reduction_price"
                                                    :style="{color: scope.row.reduction_info.reduction_type == 2 ? '#FF3030' : '#FDA623', borderColor: scope.row.reduction_info.reduction_type == 2 ? '#FF3030' : '#FDA623', margin: index == 1 ? (scope.row.reduction_info.list.length == 2 ? '0 0 0 12px' : '12px') : '0'}"
                                                >
                                                    满{{ item.require_num }}{{ scope.row.reduction_info.reduction_type == 2 ? '' : '件' }}减{{ item.reduction_price }}
                                                </div>
                                            </div>
                                        </div>
                                        <div
                                            :style="{height: '28px', display: 'flex', alignItems: 'center', marginTop: '18px'}"
                                            v-if="scope.row.reduction_info.list.length > 3"
                                        >
                                            <div
                                                v-for="(item, index) in scope.row.reduction_info.list"
                                                :key="index"
                                            >
                                                <div
                                                    v-if="index > 2"
                                                    class="reduction_price"
                                                    :style="{color: scope.row.reduction_info.reduction_type == 2 ? '#FF3030' : '#FDA623', borderColor: scope.row.reduction_info.reduction_type == 2 ? '#FF3030' : '#FDA623', margin: index == 4 ? (scope.row.reduction_info.list.length == 5 ? '0 0 0 12px' : '12px') : '0'}"
                                                >
                                                    满{{ item.require_num }}{{ scope.row.reduction_info.reduction_type == 2 ? '' : '件' }}减{{ item.reduction_price }}
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div
                                        v-else
                                        :style="{width: '100%', textAlign: 'center'}"
                                    >
                                        暂无数据
                                    </div>
                                    <el-button
                                        slot="reference"
                                        type="text"
                                    >
                                        查看
                                    </el-button>
                                </el-popover>
                            </div>
                        </template>
                    </el-table-column>
                    <el-table-column
                        width="110"
                        label="佣金比例"
                        align="center"
                    >
                        <template slot-scope="scope">
                            <div class="comp">
                                <template v-if="scope.row.goods_type == 2">
                                    {{ scope.row.goods_commission_rate | commissionRateFilter }}
                                </template>
                                <template v-else>
                                    <el-popover
                                        placement="bottom"
                                        trigger="click">
                                        <div
                                            class="spec-list"
                                            v-if="scope.row.specList">
                                            <div
                                                class="spec-line"
                                                v-for="(specItem, specIndex) in scope.row.specList"
                                                :key="specIndex">
                                                {{ specItem | specFilter }}
                                            </div>
                                        </div>
                                        <el-button
                                            slot="reference"
                                            type="text"
                                            @mouseenter.native="fnGetSpec(scope.row)">查看</el-button>
                                    </el-popover>
                                </template>
                            </div>
                        </template>
                    </el-table-column>
                    <el-table-column
                        width="110"
                        label="优惠券"
                        sortable="custom"
                    >
                        <template slot-scope="scope">
                            <span v-if="Number(filterData.goods_type) !== 4 ">{{ scope.row.coupon_money }}</span>
                            <span v-if="Number(filterData.goods_type) == 4 ">0</span>
                        </template>
                    </el-table-column>
                    <el-table-column
                        width="110"
                        label="运费设置"
                        sortable="custom"
                    >
                        <template slot-scope="scope">
                            <span v-if="Number(filterData.goods_type) !== 4 ">{{ scope.row.goods_freight }}</span>
                            <span v-if="Number(filterData.goods_type) == 4 ">0</span>
                        </template>
                    </el-table-column>
                    <el-table-column
                        prop="goods_type"
                        show-overflow-tooltip
                        width="110"
                        label="商品种类"
                    >
                        <template slot-scope="scope">
                            <span>{{ scope.row.goods_type | setGoodsType }}</span>
                        </template>
                    </el-table-column>
                    <el-table-column
                        prop="type_name"
                        width="110"
                        label="商品分类"
                    />
                    <el-table-column
                        width="110"
                        label="二级分类"
                    >
                        <template slot-scope="scope">
                            <div
                                @click="fnSetTypename(scope.row)"
                                style="cursor:pointer"
                            >
                                <span>{{ scope.row.sub_type_name }}</span>
                                <i
                                    v-if="scope.row.sub_type_name !== '--'"
                                    class="el-icon-edit"
                                />
                            </div>
                        </template>
                    </el-table-column>
                    <el-table-column
                        label="所属代理类目"
                        :width="150"
                        show-overflow-tooltip
                    >
                        <template slot-scope="scope">
                            <div
                                class="cursor-font"
                                @click="fnSetAgent(scope.row)"
                            >
                                {{ scope.row.agent_cate_name ? scope.row.agent_cate_name : '--' }}
                            </div>
                        </template>
                    </el-table-column>
                    <el-table-column
                        prop="school_filter_status"
                        label="是否设置学校权限"
                        show-overflow-tooltip
                        :width="150"
                        :formatter="emptyFormatter"
                    >
                        <template slot-scope="scope">
                            <el-button
                                type="text"
                                v-if="scope.row.school_filter_status == 1"
                                @click="fnSetAuthor(scope.row)"
                            >是</el-button>
                            <p v-if="scope.row.school_filter_status == 0">否</p>
                        </template>
                    </el-table-column>
                    <el-table-column
                        sortable="custom"
                        prop="goods_sort"
                        label="排序"
                    >
                        <template slot-scope="scope">
                            <div class="sort-wrap">
                                {{ scope.row.goods_sort }}
                                <span class="sort-spliter" />
                                <el-button
                                    type="text"
                                    class="btn-sort"
                                    @click="fnEditSort(scope.row, 'goods_sort')"
                                >
                                    <i class="el-icon-edit" />
                                </el-button>
                            </div>
                        </template>
                    </el-table-column>
                    <el-table-column
                        sortable="custom"
                        prop="goods_sale"
                        label="真实销量"
                        width="110"
                    />
                    <el-table-column
                        sortable="custom"
                        prop="goods_sale_base"
                        width="110"
                        label="商品销量"
                    >
                        <template slot-scope="scope">
                            <div class="sort-wrap">
                                {{ scope.row.goods_sale_base }}
                                <span class="sort-spliter" />
                                <el-button
                                    type="text"
                                    class="btn-sort"
                                    @click="fnEditSort(scope.row, 'goods_sale_base')"
                                >
                                    <i class="el-icon-edit" />
                                </el-button>
                            </div>
                        </template>
                    </el-table-column>
                    <el-table-column
                        header-align="left"
                        prop="autoinc_sale"
                        width="200"
                        label="是否销量自增长"
                        show-overflow-tooltip
                    >
                        <template slot-scope="scope">
                            <p
                                v-if="scope.row.goods_type == 1 || scope.row.goods_type == 4"
                            >
                                <span v-if="scope.row.autoinc_sale.autoinc_no == ''">
                                    否
                                </span>
                                <span v-if="scope.row.autoinc_sale.autoinc_no !== ''">
                                    是（{{ scope.row.autoinc_sale.inc_count_min ? scope.row.autoinc_sale.inc_count_min * 24 : 0 }} - {{ scope.row.autoinc_sale.inc_count_max ? scope.row.autoinc_sale.inc_count_max * 24 : 0 }} 个/天）
                                </span>
                            </p>
                            <p v-else>--</p>
                        </template>
                    </el-table-column>
                    <el-table-column
                        :formatter="emptyFormatter"
                        prop="goods_view"
                        width="110"
                        label="商品浏览量"
                    />
                    <el-table-column
                        header-align="left"
                        prop="autoinc_view"
                        width="200"
                        label="是否浏览量自增长"
                        show-overflow-tooltip
                    >
                        <template slot-scope="scope">
                            <p
                                v-if="scope.row.goods_type == 1 || scope.row.goods_type == 4"
                            >
                                <span v-if="scope.row.autoinc_view.autoinc_no == ''">
                                    否
                                </span>
                                <span v-if="scope.row.autoinc_view.autoinc_no !== ''">
                                    是（{{ scope.row.autoinc_view.inc_count_min ? scope.row.autoinc_view.inc_count_min * 24 : 0 }} - {{ scope.row.autoinc_view.inc_count_max ? scope.row.autoinc_view.inc_count_max * 24 : 0 }} 个/天）
                                </span>
                            </p>
                            <p v-else>--</p>
                        </template>
                    </el-table-column>
                    <el-table-column
                        prop="create_time"
                        width="140"
                        label="创建时间"
                        sortable="custom"
                    >
                        <template slot-scope="scope">
                            <template v-if="scope.row.create_time">{{ scope.row.create_time*1000 | dateFormatter('yyyy/MM/dd HH:mm') }}</template>
                            <template v-else>--</template>
                        </template>
                    </el-table-column>
                    <el-table-column
                        prop="shelf_time"
                        width="140"
                        label="上架时间"
                    >
                        <template slot-scope="scope">
                            <template v-if="scope.row.shelf_time">{{ scope.row.shelf_time*1000 | dateFormatter('yyyy/MM/dd HH:mm') }}</template>
                            <template v-else>--</template>
                        </template>
                    </el-table-column>
                    <el-table-column
                        prop="expire_time"
                        width="140"
                        label="下架时间"
                    >
                        <template slot-scope="scope">
                            <template v-if="scope.row.expire_time">{{ scope.row.expire_time*1000 | dateFormatter('yyyy/MM/dd HH:mm') }}</template>
                            <template v-else>--</template>
                        </template>
                    </el-table-column>
                    <el-table-column
                        :formatter="emptyFormatter"
                        prop="hire_settle_status"
                        width="110"
                        label="是否入驻商城"
                    >
                        <template slot-scope="scope">
                            <span v-if="scope.row.hire_settle_status == 1">已入驻</span>
                            <span
                                v-if="scope.row.hire_settle_status == 0"
                                style="color: #F95B56"
                            >
                                未入驻
                            </span>
                        </template>
                    </el-table-column>
                    <el-table-column
                        prop="audit_status"
                        width="100"
                        label="审核状态"
                    >
                        <template slot-scope="scope">
                            <div class="task-review-status">
                                <template v-if="scope.row.audit_status == -1">
                                    <span class="status deny">审核不通过</span>
                                </template>
                                <template v-if="scope.row.audit_status == 0">
                                    <span class="status wait-submit">待审核</span>
                                </template>
                                <template v-if="scope.row.audit_status == 1">
                                    <span class="status completed">审核通过</span>
                                </template>
                            </div>
                        </template>
                    </el-table-column>
                    <el-table-column
                        prop="goods_status"
                        width="100"
                        label="上架状态"
                    >
                        <template slot-scope="scope">
                            <el-switch
                                v-model="scope.row.goods_status"
                                :disabled="scope.row.audit_status != 1"
                                :active-value="1"
                                :inactive-value="0"
                                @change="fnSetStatus(scope.row)"/>
                        </template>
                    </el-table-column>
                    <el-table-column
                        sortable="custom"
                        prop="cate_type_goods_sort"
                        label="商品组分类商品排序"
                        v-if="groupType == 2"
                        :width="180"
                    >
                        <template slot-scope="scope">
                            <div class="sort-wrap">
                                {{ scope.row.cate_type_goods_sort }}
                                <span class="sort-spliter" />
                                <el-button
                                    type="text"
                                    class="btn-sort"
                                    @click="fnEditSortCate(scope.row, 'cate_type_goods_sort')"
                                >
                                    <i class="el-icon-edit" />
                                </el-button>
                            </div>
                        </template>
                    </el-table-column>
                    <el-table-column
                        :formatter="emptyFormatter"
                        v-if="filterData.goods_type == '4' "
                        prop="goods_price"
                        width="110"
                        label="商圈优惠价"
                    />
                    <el-table-column
                        prop="cate_type_names"
                        label="商品组分类"
                        show-overflow-tooltip
                        :formatter="emptyFormatter"
                        :width="110"
                        fixed="right"
                        v-if="groupType"
                    >
                        <template slot-scope="scope">
                            <p v-if="scope.row.cate_type_names">
                                {{ scope.row.cate_type_names }}
                            </p>
                            <p v-else>
                                无分类
                            </p>
                        </template>
                    </el-table-column>
                    <el-table-column
                        label="操作"
                        align="left"
                        width="220"
                        fixed="right"
                    >
                        <template slot-scope="scope">
                            <div class="option-btn-group">
                                <el-button
                                    type="text"
                                    class="btn-delete"
                                    @click="fnDeleteGoods(scope.row)">删除</el-button>
                                <el-button
                                    type="text"
                                    v-if="scope.row.goods_type == 1 || scope.row.goods_type == 4 "
                                    @click="handleRoute('shopQuestion', {
                                        goods_no: scope.row.goods_no,
                                        page: page.now_page,
                                        filterData: JSON.stringify(filterData)
                                })">问答</el-button>
                                <!-- 自营商品会有审核操作 -->
                                <template v-if="scope.row.goods_type == 1 || scope.row.goods_type == 8">
                                    <el-button
                                        type="text"
                                        :disabled="scope.row.audit_status == 1 || scope.row.hire_settle_status == 0"
                                        @click="fnAudit(scope.row, 1)">审核通过</el-button>
                                    <el-button
                                        type="text"
                                        :disabled="scope.row.audit_status == -1"
                                        @click="fnAudit(scope.row, -1)">审核不通过</el-button>
                                </template>
                                <el-button
                                    type="text"
                                    @click="fnLabel(scope.row)">打标签</el-button>
                                <el-button
                                    type="text"
                                    @click="fnSetAuthor(scope.row)">设置学校权限</el-button>
                                <el-button
                                    type="text"
                                    v-if="scope.row.cate_recommend == 0 && is_cate"
                                    @click="fnSetCateRecommend(scope.row, 1)">设为精选</el-button>
                                <el-button
                                    type="text"
                                    v-if="scope.row.cate_recommend == 1 && is_cate"
                                    @click="fnSetCateRecommend(scope.row, 0)">取消精选</el-button>
                                <el-button
                                    type="text"
                                    v-if="groupType"
                                    @click="fnEditGroup(scope.row)">编辑商品组</el-button>
                                <el-button
                                    type="text"
                                    v-if="groupType == 1"
                                    @click="fnRemoveGroup(scope.row)">移出商品组</el-button>
                                <el-button
                                    type="text"
                                    v-if="groupType == 2"
                                    @click="fnRemoveGroupChild(scope.row)">移出此分类</el-button>
                                <el-button
                                    type="text"
                                    @click="goMaterialList(scope.row)">查看素材库</el-button>
                            </div>
                        </template>
                    </el-table-column>
                </el-table>
            </div>
            <!-- /table -->

            <!-- /分页 -->
            <div class="pagination-wrapper clearfix">
                <div class="op-view">
                    <el-checkbox
                        label="当页全选"
                        v-model="checkedAll"
                        :indeterminate="checkIndeterminate"
                        :disabled="tableData.length === 0"
                        @change="fnChangeChecked"
                    />
                    <el-dropdown
                        :hide-on-click="false"
                        :class="multipleSelection.length === 0 ? '' : 'el-pagage-cursor'"
                        @command="handleCommand"
                    >
                        <el-button
                            type="text"
                            size="medium"
                            style="margin-left: 12px"
                            :disabled="multipleSelection.length === 0"
                        >
                            商品批量操作选项
                        </el-button>
                        <el-dropdown-menu slot="dropdown">
                            <el-dropdown-item
                                v-for="(item,index) in menuList"
                                :key="index"
                                :command="item"
                            >
                                {{ item }}
                            </el-dropdown-item>
                        </el-dropdown-menu>
                    </el-dropdown>
                    <el-pagination
                        layout="total,sizes, prev, pager, next, jumper"
                        background
                        :current-page.sync="page.now_page"
                        :total="page.total_count"
                        :page-size="page.page_size"
                        @current-change="getTableData"
                        @size-change="handleSizeChange"
                    />
                </div>
            </div>
        </div>
        <!-- 预览图片 -->
        <img-preview ref="preview"/>

        <!-- 导入淘客商品 -->
        <import-tao-goods
            ref="importTaoGoods"
            :type-list="typeList"
            @update="getTableData(1)"
        />
        <!-- 设置商品类目弹窗 -->
        <change-goods-type
            ref="changeGoodsType"
            :type-list="typeList"
            @confirm="fnConfirmTypeName($event)"
        />
        <!-- 设置商品代理弹窗 -->
        <change-goods-agent-cate
            ref="changeGoodsAgentCate"
            @confirm="fnConfirmAgent($event)"
        />
        <!-- 选择学校 这个弹窗有点乱 没敢改 -->
        <el-dialog
            title="选择学校"
            width="1048px"
            custom-class="choose-dialog"
            :visible.sync="showChooseSchool"
        >
            <el-cascader
                v-model="selectedCity"
                placeholder="请选择城市"
                :options="cities"
                :props="props"
                filterable
                size="small"
                style="width: 120px;marginBottom:15px"
                @change="fnChangeCity"
            />
            <el-input
                placeholder="请输入搜索内容"
                v-model.trim="searchKey"
                size="small"
                style="width: 380px"
                @keyup.native.enter="fnSearchSchool()"
            >
                <el-button
                    slot="append"
                    icon="el-icon-search"
                    @click="fnSearchSchool()"
                />
            </el-input>
            <div
                class="el-tag-school"
                v-if="isSchool"
            >
                <el-tag
                    :key="tag"
                    v-for="tag in selectedSchools"
                    closable
                    :disable-transitions="false"
                    @close="handleCloseSchool(tag)"
                >
                    {{ JSON.parse(tag).name }}
                </el-tag>
            </div>
            <div class="splider" />
            <div class="school-list">
                <div
                    class="empty"
                    v-if="schoolList.length <= 0"
                >
                    请切换城市
                </div>
                <el-checkbox-group
                    v-model="selectedSchools"
                    size="small"
                    v-else
                >
                    <el-checkbox-button
                        v-for="(school, schoolIndex) in schoolList"
                        :label="JSON.stringify({
                            id: school.id,
                            name: school.name
                        })"
                        :key="schoolIndex"
                    >{{ school.name }}</el-checkbox-button>
                </el-checkbox-group>
            </div>
            <div
                class="el-school-filter"
            >
                <p style="color:#7e8993;paddingRight:8px">设置学校权限:</p>
                <el-switch
                    v-model="filter_status"
                    active-color="#13ce66"
                    :active-value="1"
                    :inactive-value="0"
                />
            </div>
            <el-button
                type="primary"
                size="small"
                class="submit-btn"
                @click="fnSchooldAuthor()"
            >确定</el-button>
        </el-dialog>
        <!-- 选择学校 -->
        <!-- 设置商品组 -->
        <shop-group
            ref="shopGroup"
            @sendData="getData"
        />
        <!-- 设置商品组 -->
        <set-goods-tags
            ref="setGoodsTags"
        />

        <!-- 添加0元购提示信息 -->
        <el-dialog
            title="添加结果"
            :visible.sync="dialogVisibleList"
            width="860px"
            :close-on-click-modal="false"
            class="shopAdd_result"
        >
            <p class="shop_tips_title">*只能推荐淘礼金金额 - 佣金金额小于等于5元，且已上架的淘客商品</p>
            <el-table
                :data="tableDateResh"
                max-height="400"
                style="width: 100%;"
                border
            >
                <el-table-column
                    label="序号"
                    type=index
                    :width="60"
                />
                <el-table-column
                    prop="goods_no"
                    label="商品编号"
                    show-overflow-tooltip
                    align="center"
                    :width="140"
                />
                <el-table-column
                    prop="msg_info"
                    label="商品信息"
                    show-overflow-tooltip
                    align="center"
                />
                <el-table-column
                    prop="msg_code"
                    label="添加结果"
                    show-overflow-tooltip
                    align="center"
                    :width="100"
                >
                    <template slot-scope="scope">
                        <span
                            v-if="scope.row.msg_code == 1"
                            class="shop_addInfo_sucess"
                        >成功</span>
                        <span
                            v-if="scope.row.msg_code == 0"
                            class="shop_addInfo_error"
                        >失败</span>
                    </template>
                </el-table-column>
            </el-table>
        </el-dialog>
        <!-- /添加0元购提示信息 -->
        <!-- 设置商品自动增长 -->
        <el-dialog
            title="自动增长量"
            :visible.sync="dialogVisiblBrowse"
            width="510px"
        >
            <div style="display:flex">
                <p style="white-space: nowrap">
                    选择规则:
                </p>
                <div style="display:flex;flex-wrap:wrap">
                    <div
                        style="marginBottom: 15px;marginLeft:30px;"
                        v-for="(item,index) in browseList"
                        :key="index"
                    >
                        <el-radio
                            v-model="browse"
                            :label="item.autoinc_no"
                        >
                            <span>{{ item.inc_count_min }} - {{ item.inc_count_max }}个/小时</span>
                        </el-radio>
                    </div>
                </div>
            </div>
            <div style="display:flex;margin-top:24px">
                <p style="white-space: nowrap">
                    选择规则:
                </p>
                <div style="display:flex;flex-direction: column;margin-left:30px">
                    <el-radio-group v-model="browseData.browse_type">
                        <el-radio :label="0">
                            不限制
                        </el-radio>
                        <el-radio :label="1">
                            <el-date-picker
                                v-model="browseData.browse_date"
                                type="datetimerange"
                                :picker-options="browsePickerOptions()"
                                range-separator="至"
                                start-placeholder="开始日期"
                                end-placeholder="结束日期"
                                align="right"
                                size="small"
                                :default-time="['00:00:00','23:59:59']"
                                style="width:90%;margin-top:10px;"
                            />
                        </el-radio>
                    </el-radio-group>
                </div>
            </div>
            <span
                slot="footer"
                class="dialog-footer">
                <el-button
                    @click="dialogVisiblBrowse = false"
                    size="small"
                >取 消</el-button>
                <el-button
                    type="primary"
                    size="small"
                    @click="fnConfirmBrowse()">确 定</el-button>
            </span>
        </el-dialog>
        <!-- /设置商品自动增长 -->
    </section>
</template>

<script>
import {back} from "@/mixin/back";
import ImgPreview from "@/components/common/img-preview";
import ImportTaoGoods from "@/components/goods/import-tao-goods";
import ChangeGoodsType from "@/components/goods/change-goods-type";
import ChangeGoodsAgentCate from "@/components/goods/change-goods-agent-cate";
import shopGroup from '@/components/student/shop-group';
import SetGoodsTags from "@/components/goods/set-goods-tags";

export default {
    name: 'GoodsListNext',
    mixins: [back],
    components: {
        SetGoodsTags,
        ChangeGoodsAgentCate,
        ChangeGoodsType,
        ImportTaoGoods,
        ImgPreview,
        shopGroup
    },
    data() {
        return {
            groupType: '',
            is_cate: false,
            goods_no: '',
            filterData: {
                // 选中分类
                selectedType: [],
                // 商品类型
                goods_type: '',
                // 商品名称
                goods_title: '',
                // 店铺名称
                shop_title: '',
                audit_status: '',
                cate_no: '',
                cate_type_no: '',
                goodType: [],
                shop_no: '',
                sort_field: '',
                sort_type: '',
                tuan_price_range: '',
                tuan_price_rangeEnd: '',
                origin_price_range: '',
                origin_price_rangeEnd: '',
                coupon_money_range: '',
                coupon_money_rangeEnd: '',
                commission_money_range: '',
                commission_money_rangeEnd: '',
                sale_range: '',
                sale_rangeEnd: '',
                tuan_num: '',
                goods_status: '',
                money_range_start: '',
                money_range_end: '',
                price_range_start: '',
                price_range_end: '',
                cate_no_type: '',
                goods_price_pay_start: '',
                goods_price_pay_end: '',
                set_cate_recommend: ''
            },
            volume: 99,
            autoinc_view_set: 99,
            school_filter_status: 99,
            // 展开收起
            isFold: true,
            checkedAll: false,
            checkIndeterminate: false,
            tableData: [],
            tableLoading: false,
            page: {
                now_page: 1,
                total_count: 0,
                page_size: 20
            },
            dateTimeRange: [],
            // 商品分类列表
            typeList: [],
            // 商品组下拉
            typeAllListType: [],
            // 商品类型下拉
            goodsTypeList: [
                {label: '全部', value: ''},
                {label: '自营', value: 1},
                {label: '合作淘客', value: 2},
                {label: '其它淘客', value: 3},
                {label: '商圈商品', value: 4},
                // {label: '二手商品', value: 10},
            ],
            // 审核状态
            verifyList: [
                {value: '', label: '全部'},
                {value: 1, label: '待审核'},
                {value: 2, label: '审核通过'},
                {value: 3, label: '审核不通过'}
            ],
            // 上架状态下拉
            statusList: [
                {value: '', label: '全部'},
                {value: 1, label: '已上架'},
                {value: -1, label: '已下架'},
            ],
            optionList: [
                {value: 99, label: '全部'},
                {value: 1, label: '是'},
                {value: 0, label: '否'},
            ],
            // 选中数据
            multipleSelection: [],
            // 修改商品分类批量还是单独
            is_batch_setting: 0,
            // 操作的商品编号
            menuList: [
                '推荐到商品组',
                '批量审核通过',
                '批量下架',
                '批量上架',
                '推荐到0元购',
                '添加自动销量',
                '移除自动销量',
                '批量删除商品',
                '推荐到秒杀',
                '设置学校权限',
                '添加自动浏览量',
                '移除自动浏览',
                '编辑商品分类',
                '设置类目代理',
            ],

            showChooseSchool: false,
            selectedCity: [],
            cities: [],
            searchKey: '',
            // 弹窗当前显示学校集合
            schoolList: [],
            // 当前选中的学校
            selectedSchools: [],
            //所有学校集合
            city_schools: {},
            isSchool: true,
            filter_status: 1,
            props: {
                value: 'id',
                label: 'name',
                children: 'children'
            },
            tableDateResh: [],
            dialogVisibleList: false,
            browseList: [],
            add_shop_type: '',
            browseData: {
                browse_type: 0,
                browse_date: []
            },
            dialogVisiblBrowse: false,
            browse: '',
        };
    },
    computed: {},
    filters: {
        specFilter(val){
            if(!val){
                return '--';
            }
            let str = '';

            for(var i in val.spec_list){
                str += val.spec_list[i].spec_name + ':' + val.spec_list[i].spec_value;
                if(i < val.spec_list.length){
                    str += ',';
                }else{
                    str += ': ';
                }
            }

            if(str){
                str += '佣金' + val.product_commission+'元';
            }
            return str;
        },
        commissionRateFilter(val){
            if(val <= 0){
                return '--';
            }
            return val*1 + '%';
        },
        setGoodsType (val) {
            if (val == 1) {
                return '自营';
            } else if (val == 2) {
                return '合作淘客';
            } else if (val == 3) {
                return '普通淘客';
            } else if (val == 4) {
                return '商圈商品';
            } else if (val == 10) {
                return '二手商品';
            }
        }
    },
    watch: {
        dateTimeRange(value) {
            this.filterData.start_time = value ? value[0] / 1000 : '';
            this.filterData.end_time = value ? value[1] / 1000 : '';
            this.getTableData(1);
        },
        showChooseSchool (val) {
            this.fnGetSchoolList();
        },
    },

    mounted() {
        this.$store.commit('SET_HEADER', [{title: "APP后台"}, {title: '商城'}, {title: '商品列表'}]);
        this.authResult = this.$route.meta.authResult;
        this.getUrl();
        this.init();
        this.getTableData();
        this.getTypeList();
        this.fnGetSchoolList();
    },

    methods: {

        /**
         * 获取url参数
         */
        getUrl () {
            let query = this.$route.query;

            if (query.shop_title !== undefined ) {
                this.filterData.shop_title = query.shop_title;
            } else if (query.page !== undefined || query.filterData !== undefined) {
                this.page.now_page = Number(query.page);
                this.filterData = JSON.parse(query.filterData);
            }
        },

        /**
         * 初始化
         */
        init() {
            this.$store.commit('SET_HEADER', [
                {
                    title: "APP后台",
                },
                {
                    title: "商城",
                },
                {
                    title: '商品列表'
                }
            ]);
            let searchType = [];

            if(this.$route.query.type_no){
                searchType.push(this.$route.query.type_no);
                if(this.$route.query.sub_type_no){
                    this.filterData.cate_no_type = this.$route.query.sub_type_no;
                    searchType.push(this.$route.query.sub_type_no);
                }
                if(this.$route.query.is_cate) {
                    this.is_cate = this.$route.query.is_cate;
                }
                if(this.$route.query.cate_recommend) {
                    this.$set(this.filterData, 'set_cate_recommend', Number(this.$route.query.cate_recommend));
                }
                // if(this.$route.query.has_type) {
                //     this.ification = 0;
                // }
            }

            if(this.$route.query.goods_title || this.$route.query.shop_title){
                this.filterData.goods_title = this.$route.query.goods_title;
                this.filterData.shop_title = this.$route.query.shop_title;
            }

            if(this.$route.query.shop_no) {
                this.filterData.shop_no = this.$route.query.shop_no;
            }

            //商城数据大盘排名前100匹配
            if(this.$route.query.goods_title && this.$route.query.goods_type) {
                this.filterData.goods_title = this.$route.query.goods_title;
                if(this.$route.query.goods_type == 'e_ticket'){
                    this.filterData.goods_type = 4;
                } else if (this.$route.query.goods_type == 'self') {
                    this.filterData.goods_type = 1;
                } else if (this.$route.query.goods_type == 'tao') {
                    this.filterData.goods_type = 3;
                }
            }

            //商品组/分类管理
            if(this.$route.query.sub_type_no && this.$route.query.cate_type_no) {
                this.filterData.cate_no_type = this.$route.query.sub_type_no;
                this.filterData.cate_type_no = this.$route.query.cate_type_no;
            }

            //区分是否从商品组跳转
            if(this.$route.query.sub_type_no && this.$route.query.is_group) {
                this.groupType = Number(this.$route.query.is_group);

                if(this.groupType == 1) {
                    this.menuList.unshift('移出商品组');
                }else if(this.groupType == 2) {
                    this.menuList.unshift('移出此分类');
                }
            }

            if(this.$route.query.is_cate) {
                this.is_cate = this.$route.query.is_cate;
            }

            this.filterData.is_chosen = this.$route.query.is_chosen ? (this.$route.query.is_chosen+'') : '';

            this.filterData.selectedType = searchType;
            this.getTableData();
        },

        /**
         * @description 获取商品分类列表
         */
        getTypeList() {
            this.$post('/student/shop_goods_type%5Cget_list_linkage', {}, resp => {
                if(resp.code === 1){
                    this.typeList = resp.data.list;
                }
            });
            this.$post('/student/shop_goods_cate%5Cget_list_select',{},resp=>{
                if (resp.code === 1) {
                    this.typeAllListType = resp.data.list;
                }
            });
        },

        /**
         * @description 获取列表数据
         * @param page
         */
        getTableData(page) {
            this.tableLoading = true;
            let querys = this.$route.query;

            if(querys.type_no && querys.sub_type_no) {
                this.filterData.cate_no_type = '';
            }

            let params = {
                type_no: '',
                sub_type_no: '',
                goods_type: this.filterData.goods_type,
                goods_status: this.filterData.goods_status,
                audit_status: this.filterData.audit_status,
                goods_title: this.filterData.goods_title,
                shop_title:this.filterData.shop_title,
                page_id: page || this.page.now_page,
                sort_field: this.filterData.sort_field,
                sort_type: this.filterData.sort_type,
                is_chosen: this.filterData.is_chosen,
                rights_money_range: this.filterData.money_range_start + '-' + this.filterData.money_range_end,
                commission_money_range: this.filterData.commission_money_range + '-' + this.filterData.commission_money_rangeEnd,
                cate_no: this.filterData.cate_no_type,
                cate_recommend: this.filterData.set_cate_recommend,
                cate_type_no: this.filterData.cate_type_no,
                autoinc_sale_set: this.volume,
                school_filter_status: this.school_filter_status,
                autoinc_view_set: this.autoinc_view_set,
                shop_no: this.filterData.shop_no
            };

            if (this.filterData.selectedType && this.filterData.selectedType.length >= 1) {
                if(this.filterData.selectedType[0] == '*'){
                    params.cate_no = '*';
                }else{
                    params.type_no = this.filterData.selectedType[0];
                }
            }

            if (this.filterData.selectedType && this.filterData.selectedType.length == 2) {
                if(this.filterData.selectedType[0] == '*'){
                    params.cate_no = this.filterData.selectedType[1];
                }else{
                    params.type_no = this.filterData.selectedType[0];
                    params.sub_type_no = this.filterData.selectedType[1];
                }
            }

            params.page_id = page || this.page.now_page;
            params.page_size = this.page.page_size;
            this.$post('/student/shop_goods%5Cget_list', params, res => {
                if (res.code === 1) {
                    this.tableData = res.data.list;
                    this.page = res.data.page;
                    this.checkedAll = false;
                } else {
                    this.$notify({
                        title: '提示',
                        message: res.msg,
                        type: 'warning',
                        duration: 2000
                    });
                }
                this.tableLoading = false;
            });
        },

        /**
         * @description 过滤函数
         */
        emptyFormatter(row, column, val) {
            if (!val) return '--';
            return val;
        },

        /**
         * 自定义表格标题hover提示
         */
        renderHeader(h,title, content){
            return h('span', {}, [
                h('span', {style: 'font-weight: bold'}, title),
                h('el-popover', { props: { placement: 'top-start', width: '200', trigger: 'hover', content: content }}, [
                    h('i', { slot: 'reference', class:'el-icon-question', style: 'color:#666;margin-left: 6px'}, '')
                ])
            ]);
        },

        /**
         * 路由跳转
         * @param routeName
         * @param query
         */
        handleRoute(routeName, query) {
            this.$router.push({
                name: routeName,
                query
            });
        },

        /**
         * 预览图片
         * @param   {String}    images      //单图预览
         * @param   {Array}     images      //多图预览
         * @param index
         */
        fnShowPreview(images, index) {
            if (images && Object.prototype.toString.call(images) == '[object String]') {
                this.$refs.preview.show([
                    images
                ]);
            } else if (images && Object.prototype.toString.call(images) == '[object Array]') {
                this.$refs.preview.show(images, index);
            } else {
                this.$message({
                    type: 'warning',
                    message: '图片类型错误'
                });
            }
        },

        /**
         * 筛选精选商品
         */
        fnSetCate () {
            if(this.filterData.cate_no_type == '' || this.filterData.cate_no_type == null) {
                this.$message({
                    type: 'warning',
                    message: '请先选择商品组,商品组不为空时生效'
                });
                return;
            }
            this.getTableData(1);
        },

        /**
         * 重置
         */
        handleReset () {
            let list = JSON.stringify(this.filterData);
            let newList = JSON.parse(list);

            // this.ification = '';
            this.volume = this.autoinc_view_set = this.school_filter_status = 99;
            for(let i in newList){
                newList[i] = '';
            }

            this.filterData = {
                ...newList
            };
            this.getTableData(1);
        },

        /**
         * 排序
         */
        handleSortChanged(data) {

            let sortTypeMap = {
                ascending: 'asc',
                descending: 'desc'
            };

            let sortFieldMap = {
                "goods_sale": 'sale',
                "goods_sale_base": 'sale_base',
                "goods_sort": 'sort',
                "tuan_num": "tuan_num",
                "tuan_price": "tuan_price",
                "goods_price_origin": "origin_price",
                "coupon_money": "coupon_money",
                "goods_freight": "freight",
                "goods_commission": "commission",
                "goods_price": "goods_price",
                "goods_price_pay": "goods_price_pay",
                "create_time": "create_time",
                "cate_type_goods_sort": "cate_type_goods_sort"
            };

            if (data.order) {
                this.filterData.sort_field = sortFieldMap[data.prop];
                this.filterData.sort_type = sortTypeMap[data.order];
            } else {
                this.filterData.sort_field = '';
                this.filterData.sort_type = '';
            }

            this.getTableData();
        },

        /**
         * 勾选
         * @param selection
         */
        fnSelect(selection) {
            this.checkedAll = selection.length == this.tableData.length;

            // 改变全选checkbox 的显示状态
            this.checkIndeterminate = selection.length > 0 && selection.length < this.tableData.length;
        },
        fnSelectAllTop(selection) {
            this.checkedAll = selection.length > 0;

            // 改变全选checkbox 的显示状态
            this.checkIndeterminate = selection.length > 0 && selection.length < this.tableData.length;
        },
        fnChangeChecked() {
            if(this.checkedAll){
                this.toggleSelection(1);
            }else{
                this.toggleSelection();
            }
        },
        toggleSelection(rows) {
            if (rows) {
                this.$refs.goodsTable.toggleAllSelection();
            } else {
                this.$refs.goodsTable.clearSelection();
            }
        },
        handleSelectionChange(val) {
            this.multipleSelection = val;
        },

        /**
         * 跳转商品详情页
         */
        fnGoShoplist (row) {
            if (row.goods_url !== '' && row.goods_type !== 1) {
                window.open(row.goods_url);
                return;
            }

            if(row.goods_url == '' && (row.goods_type !== 1 && row.goods_type !== 8)) {
                this.$message({
                    type: 'warning',
                    message: '链接不可以为空'
                });
                return;
            }

            if(row.goods_type == 1 || row.goods_type == 8) {
                const routeData = this.$router.resolve({
                    name: 'goodsDetail',
                    query: {
                        no: row.goods_no
                    }
                });

                window.open(routeData.href, '_blank');
                // v2.0.7改为总后台商品详情
                /*this.$post('/wei4/hire_user%5Cget_login_session_ticket', {
                    hire_no: row.hire_no
                }, resp => {
                    if (resp.code == 1) {
                        // window.open('http://0.0.0.0/manage/market/good-edit?no=' + row.goods_no );
                        if(window.location.host == 'phaadmin.wxhand.com') {
                            window.open('http://cms.zsdx.cn/manage/market/good-edit-group?no=' + row.goods_no + '&session_ticket=' + resp.data.session_ticket);
                        }else{
                            window.open('http://gt.wxhand.com/manage/market/good-edit-group?no=' + row.goods_no + '&session_ticket=' + resp.data.session_ticket);
                        }
                    } else {
                        this.$message({
                            type: 'warning',
                            message: resp.msg,
                            center: true
                        });
                    }
                });*/
            }
        },

        /**
         * 获取佣金比例
         * @param good
         */
        fnGetSpec(good){
            this.$post('/student/shop_goods%5Cget', {
                goods_no: good.goods_no
            }, resp => {
                if(resp.code == 1){
                    let spec = resp.data.goods_product_list;

                    this.$set(good, 'specList', spec);
                }else{
                    this.$message({
                        type: 'warning',
                        message: resp.msg
                    });
                }
            });
        },

        /**
         * 修改分类
         */
        fnSetTypename (row) {
            this.$post('/student/shop_goods%5Cget',{
                goods_no: row.goods_no
            },resp=>{
                if (resp.code === 1) {
                    this.is_batch_setting = 0;
                    this.goods_no = row.goods_no;
                    let type_name = [
                        resp.data.parent_type_no,
                        resp.data.type_no
                    ];

                    this.$refs.changeGoodsType.show(type_name);
                } else {
                    this.$notify({
                        title: '提示',
                        type: 'warning',
                        message: resp.msg
                    });
                }
            });
        },

        /**
         * 确认修改分类
         */
        fnConfirmTypeName (type_no) {
            if (!type_no) {
                this.$message({
                    type: 'warning',
                    message: '请选择分类',
                });
                return;
            }

            // 单独设置
            if(this.is_batch_setting === 0) {
                this.$post('/student/shop_goods%5Cmodify',{
                    goods_no: this.goods_no,
                    type_no
                },resp=> {
                    if (resp.code === 1) {
                        this.$refs.changeGoodsType.close();
                        this.getTableData();
                        this.$notify({
                            type: 'success',
                            message: '修改成功',
                            title: '提示'
                        });
                    } else {
                        this.$notify({
                            type: 'success',
                            message: resp.msg,
                            title: '提示'
                        });
                    }
                });
            } else {
                // 批量设置
                let goods_no = this.multipleSelection.map(item=>{
                    return item.goods_no;
                });

                setTimeout(()=>{
                    if(goods_no.length > 0) {
                        this.$post('/student/shop_goods%5Cset_type_no_batch', {
                            goods_nos: goods_no.join(),
                            type_no
                        }, resp => {
                            if (resp.code === 1) {
                                this.getTableData();
                                this.$refs.changeGoodsType.close();
                                this.$notify({
                                    type: 'success',
                                    message: '修改成功',
                                    title: '提示'
                                });
                            } else {
                                this.$notify({
                                    type: 'success',
                                    message: resp.msg,
                                    title: '提示'
                                });
                            }
                        });
                    }
                },100);
            }
        },

        /**
         * 单独设置商品代理类目
         */
        fnSetAgent (row) {
            this.goods_no = row.goods_no;
            this.is_batch_setting = 0;
            this.$refs.changeGoodsAgentCate.show(row.agent_cate_no);
        },

        /**
         * 确定设置商品代理类目
         */
        fnConfirmAgent (agent_cate_no) {
            if (!agent_cate_no) {
                this.$message({
                    type: 'warning',
                    message: '请选择代理类目',
                });
                return;
            }
            let goods_nos = [];

            // 单独设置
            if(this.is_batch_setting === 0) {
                goods_nos.push(this.goods_no);
            } else {
                goods_nos = this.multipleSelection.map(item => {
                    return item.goods_no;
                });
            }

            this.$post('/student/shop_goods%5Cset_agent_cate_no_batch', {
                goods_nos: goods_nos.join(),
                agent_cate_no
            }, resp => {
                if (resp.code === 1) {
                    this.$refs.changeGoodsAgentCate.close();
                    this.getTableData();
                    this.$notify({
                        title: '提示',
                        type: 'success',
                        message: '设置成功'
                    });
                } else {
                    this.$notify({
                        title: '提示',
                        type: 'warning',
                        message: resp.msg
                    });
                }
            });
        },

        /**
         * 批量操作
         */
        handleCommand (command) {
            if (this.multipleSelection.length === 0) {
                this.$message({
                    type: 'warning',
                    message: '请先选择商品',
                });
                return;
            }

            switch (command) {
                case '推荐到商品组':
                    this.fnShowPushDialog();
                    break;
                case '批量审核通过':
                    this.fnAudiSuccess();
                    break;
                case '移出商品组':
                    if(this.groupType) {//当从商品组和商品分类进入有此选项
                        this.fnDeleteGroup();
                    }
                    break;
                case '移出此分类':
                    if(this.groupType) {//当从商品组和商品分类进入有此选项
                        this.fnDeleteGroup();
                    }
                    break;
                case '批量下架':
                    this.fnShowPushUpper('-1');
                    break;
                case '批量上架':
                    this.fnShowPushUpper('1');
                    break;
                case '推荐到0元购':
                    this.fnRecommentZeon();
                    break;
                case '添加自动销量':
                    this.fnAddVolum(1);
                    break;
                case '移除自动销量':
                    this.fnRemoveVolum(1);
                    break;
                case '批量删除商品':
                    this.fnRemoveShop();
                    break;
                case '推荐到秒杀':
                    this.fnRecommonMs();
                    break;
                case '设置学校权限':
                    this.fnSetSchool();
                    break;
                case '添加自动浏览量':
                    this.fnAddVolum(2);
                    break;
                case '移除自动浏览':
                    this.fnRemoveVolum(2);
                    break;
                case '编辑商品分类':
                    this.is_batch_setting = 1;
                    this.$refs.changeGoodsType.show('');
                    break;
                case '设置类目代理':
                    this.is_batch_setting = 1;
                    this.$refs.changeGoodsAgentCate.show('');
                    break;
                default:
                    break;
            }
        },

        /**
         * 推荐到秒杀
         */
        fnRecommonMs () {
            let list = this.multipleSelection;

            for(let i=0; i<list.length;i++) {
                if (list[i].goods_type == 1 || list[i].goods_type == 4) {
                    this.$message({
                        type: 'warning',
                        message: '只可推荐淘客类商品',
                        center: true
                    });
                    return;
                }
            }

            let str = [];

            this.$confirm('此操作将批量添加到秒杀, 是否继续?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {
                this.multipleSelection.map(item=> {
                    str.push(item.goods_no);
                });
                this.$post('/student/shop_goods_flash_sale%5Cadd_tao_item',{
                    goods_nos: str.join()
                },resp=>{
                    if (resp.code == 1) {
                        this.$message({
                            type: 'success',
                            message: '添加成功',
                            center: true
                        });
                    } else {
                        this.$message({
                            type: 'warning',
                            message: resp.msg,
                            center: true
                        });
                    }
                });
            });
        },

        /**
         * 初始化添加自动浏览日期数据
         */
        browsePickerOptions () {
            return {
                shortcuts: [{
                    text: '最近一周',
                    onClick(picker) {
                        const end = new Date();
                        const start = new Date();

                        start.setTime(start.getTime() + 3600 * 1000 * 24 * 7);
                        picker.$emit('pick', [end, start]);
                    }
                }, {
                    text: '最近一个月',
                    onClick(picker) {
                        const end = new Date();
                        const start = new Date();

                        start.setTime(start.getTime() + 3600 * 1000 * 24 * 30);
                        picker.$emit('pick', [end, start]);
                    }
                }, {
                    text: '最近三个月',
                    onClick(picker) {
                        const end = new Date();
                        const start = new Date();

                        start.setTime(start.getTime() + 3600 * 1000 * 24 * 90);
                        picker.$emit('pick', [end, start]);
                    }
                }]
            };
        },

        /**
         * 获取商品销量套餐
         */
        fnGetAutoinc (param) {
            this.browseList = [];
            if (param == 1) {
                this.$post('/student/shop_goods_sale_autoinc%5Cget_list', {
                }, resp => {
                    if (resp.code == 1) {
                        this.browseList = resp.data.list;
                    }
                });
            } else {
                this.$post('/student/shop_goods_view_autoinc%5Cget_list', {
                }, resp => {
                    if (resp.code == 1) {
                        this.browseList = resp.data.list;
                    }
                });
            }
        },

        /**
         * 1:添加自动销量 2:自动浏览量
         */
        fnAddVolum (param) {
            this.browsePickerOptions();
            if (param == 1) {
                this.fnGetAutoinc(1);
                let list = this.multipleSelection;

                this.add_shop_type = 1;
                for(let i=0; i<list.length;i++) {
                    if (list[i].goods_type == 2 || list[i].goods_type == 3) {
                        this.$message({
                            type: 'warning',
                            message: '销量自增长,只对自营商品和商圈商品有效,请重新选择商品',
                            center: true
                        });
                        return;
                    }
                }
            } else {
                this.add_shop_type = 2;
                this.fnGetAutoinc(2);
            }
            this.browseData.browse_date = [];
            this.browseData.browse_type = 0;
            this.dialogVisiblBrowse = !this.dialogVisiblBrowse;
        },

        /**
         * 确定设置商品销量
         */
        fnConfirmBrowse () {
            this.browsePickerOptions();
            if (this.browse == '') {
                this.$message({
                    type: 'warning',
                    message: '不可以为空,请选择自动增长量',
                    center: true
                });
                return;
            }

            if (this.add_shop_type == 1) {
                this.multipleSelection.map(item=> {
                    this.$post('/student/shop_goods_sale_autoinc%5Cset_autoinc',{
                        autoinc_no: this.browse,
                        goods_no: item.goods_no
                    },resp=>{
                        if (resp.code == 1) {
                            //
                        } else {
                            this.$message({
                                type: 'warning',
                                message: resp.msg,
                                center: true
                            });
                        }
                    });
                });
            } else if (this.add_shop_type == 2) {
                if(this.browseData.browse_type == 1) {
                    if(this.browseData.browse_date === null) {
                        this.$message({
                            type: 'warning',
                            message: '请选择日期范围,不可以为空',
                            center: true
                        });
                        return false;
                    }
                    if(this.browseData.browse_date.length == 0) {
                        this.$message({
                            type: 'warning',
                            message: '请选择日期范围,不可以为空',
                            center: true
                        });
                        return false;
                    }
                }

                this.multipleSelection.map(item=> {
                    this.$post('/student/shop_goods_view_autoinc%5Cset_autoinc',{
                        autoinc_no: this.browse,
                        goods_no: item.goods_no,
                        valid_start_time: this.browseData.browse_type ? parseInt((new Date(this.browseData.browse_date[0]).getTime() / 1000)) : 0,
                        valid_end_time: this.browseData.browse_type ? parseInt((new Date(this.browseData.browse_date[1]).getTime() / 1000)) : 0
                    },resp=>{
                        if (resp.code == 1) {
                            //
                        } else {
                            this.$message({
                                type: 'warning',
                                message: resp.msg,
                                center: true
                            });
                        }
                    });
                });
            } else {
                return;
            }
            this.dialogVisiblBrowse = !this.dialogVisiblBrowse;
            this.getTableData();
            this.$message({
                type: 'success',
                message: '设置成功',
                center: true
            });
        },

        /**
         * 移除自动销量
         */
        fnRemoveVolum (param) {
            let list = this.multipleSelection;

            if (param == 1) {
                for(let i=0; i<list.length;i++) {
                    if (list[i].goods_type == 2 || list[i].goods_type == 3) {
                        this.$message({
                            type: 'warning',
                            message: '销量自增长,只对自营商品和商圈商品有效,请重新选择商品',
                            center: true
                        });
                        return;
                    }
                }
            }

            this.$confirm('此操作将移除所选中商品增长量, 是否继续?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {
                if (param == 1) {
                    this.multipleSelection.map(item=>{
                        if (item.autoinc_sale.autoinc_no !== '') {
                            this.$post('/student/shop_goods_sale_autoinc%5Cunset_autoinc',{
                                goods_no: item.goods_no
                            },resp=>{
                                if (resp.code == 1) {
                                    //
                                } else {
                                    this.$message({
                                        type: 'warning',
                                        message: resp.msg,
                                        center: true
                                    });
                                }
                            });
                        }
                    });
                } else {
                    this.multipleSelection.map(item=>{
                        if (item.autoinc_view.autoinc_no !== '') {
                            this.$post('/student/shop_goods_view_autoinc%5Cunset_autoinc',{
                                goods_no: item.goods_no
                            },resp=>{
                                if (resp.code == 1) {
                                    //
                                } else {
                                    this.$message({
                                        type: 'warning',
                                        message: resp.msg,
                                        center: true
                                    });
                                }
                            });
                        }
                    });
                }

                this.getTableData();
                this.$message({
                    type: 'success',
                    message: '移除成功',
                    center: true
                });
            });
        },

        /**
         * 批量删除商品
         */
        fnRemoveShop () {
            this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {
                let goods_json = [];

                this.multipleSelection.map(item=>{
                    goods_json.push(item.goods_no);
                });

                this.$post('/student/shop_goods%5Cdelete_batch',{
                    goods_no_json: JSON.stringify(goods_json)
                },resp=>{
                    if (resp.code == 1) {
                        this.getTableData();
                        this.$message({
                            type: 'success',
                            message: '移除成功',
                            center: true
                        });
                    } else {
                        this.$message({
                            type: 'warning',
                            message: resp.msg,
                            center: true
                        });
                    }
                });
            });
        },

        /**
         * 推荐到0元购
         */
        fnRecommentZeon () {
            let goods_no = [];
            let status = false;

            this.multipleSelection.map(item=>{
                goods_no.push(item.goods_no);
            });
            this.fnRecommentShop(goods_no);
        },
        fnRecommentShop (goods_no) {
            this.$post('/student/shop_free%5Cjoin',{
                goods_no_json: JSON.stringify(goods_no)
            },resp=>{
                this.tableDateResh = resp.data.msg_list;
                this.dialogVisibleList = !this.dialogVisibleList;
            });
        },

        /**
         * 批量上架/下架
         */
        fnShowPushUpper (type) {
            let selected = this.multipleSelection.map(val => {
                return val.goods_no;
            });

            this.$post('/student/shop_goods%5Cset_status_batch', {
                goods_no_json: JSON.stringify(selected),
                status: type
            }, resp => {
                if (resp.code == 1) {
                    this.getTableData(1);
                    this.$message({
                        type: 'success',
                        message: '操作成功'
                    });
                } else {
                    this.$message({
                        type: 'warning',
                        message: resp.msg
                    });
                }
            });
        },

        /**
         * 批量审核通过
         */
        fnAudiSuccess () {
            this.multipleSelection.forEach(option => {
                this.$post('/student/shop_goods%5Caudit', {
                    action: 'pass',
                    goods_no: option.goods_no
                }, resp => {
                    if (resp.code == 1) {
                        //
                    } else {
                        this.$message({
                            type: 'warning',
                            message: resp.msg || '操作失败'
                        });
                    }
                });
            });

            setTimeout(()=>{
                this.$message({
                    type: 'success',
                    message: '审核通过'
                });
                this.getTableData();
            },500);
        },

        fnShowPushDialog(){
            // this.checkedJingang = [];
            // this.showJingangDialog = true;
            this.$refs.shopGroup.show();
            this.$refs.shopGroup.getType('add');
        },

        /**
         * 学校权限
         */
        fnChangeCity() {
            if (this.selectedCity.length >= 2) {
                this.schoolList = this.city_schools['city_' + this.selectedCity[1]];
                this.searchKey = '';
            } else {
                this.schoolList = [];
                this.searchKey = '';
            }
        },
        fnSearchSchool() {
            if (this.selectedCity.length >= 2) {
                this.schoolList = this.city_schools['city_' + this.selectedCity[1]].filter(item => {
                    if (!this.searchKey) {
                        return true;
                    }
                    return item.name.indexOf(this.searchKey) > -1;
                });
            } else {
                this.schoolList = [];
            }
        },
        fnGetSchoolList() {
            this.$post('/student/local_info%5Cschool_tree', {
            }, resp => {
                if (resp.code == 1) {
                    // 将学校与省市剥离,方便显示以及遍历
                    let tree = resp.data.tree;
                    let cityTmp = [];
                    let schoolTmp = {};

                    tree.forEach(item => {
                        let provinceTmp = {
                            id: item.id,
                            name: item.name,
                            children: []
                        };

                        if (item.children) {
                            item.children.forEach((city) => {
                                provinceTmp.children.push({
                                    id: city.id,
                                    name: city.name
                                });
                                schoolTmp['city_' + city.id] = city.children;
                            });
                        }
                        cityTmp.push(provinceTmp);
                    });

                    this.cities = cityTmp;
                    this.city_schools = schoolTmp;
                    this.selectedCity = [12, 88];
                    this.fnChangeCity();
                }
            });
        },

        /**
         * 批量设置学校权限
         */
        fnSetSchool () {
            this.isSchool = false;
            this.selectedSchools = [];
            this.showChooseSchool = !this.showChooseSchool;
        },

        /**
         * 移除学校
         */
        handleCloseSchool (tag) {
            this.selectedSchools.splice(this.selectedSchools.indexOf(tag), 1);
        },

        /**
         * 单个设置学校权限
         */
        fnSetAuthor (row) {
            this.goods_no = row.goods_no;
            this.isSchool = true;
            this.$post('/student/shop_goods%5Cget_school_filter',{
                goods_no: row.goods_no,
            },resp => {
                if (resp.code == 1) {
                    let school = [];

                    this.showChooseSchool = !this.showChooseSchool;
                    setTimeout(()=> {
                        this.filter_status = resp.data.school_filter_status;
                        resp.data.school_filter_school_ids.map(item => {
                            this.schoolList.map(option => {
                                if (item == option.id) {
                                    school.push(JSON.stringify({
                                        id: option.id,
                                        name: option.name
                                    }));
                                }
                            });
                        });
                        this.selectedSchools = school;
                    },100);

                } else {
                    this.$message({
                        type: 'warning',
                        message: resp.msg,
                        center: true
                    });
                }
            });
        },

        /**
         * 确定设置过滤学校
         */
        fnSchooldAuthor () {
            let school_filter_school_ids = [];

            if (Object.keys(this.selectedSchools).length >= 1 ) {
                this.selectedSchools.map(item=>{
                    school_filter_school_ids.push(
                        JSON.parse(item).id
                    );
                });
            }

            if (this.isSchool) {
                this.$post('/student/shop_goods%5Cset_school_filter',{
                    goods_no: this.goods_no,
                    school_filter_status: this.filter_status,
                    school_filter_school_ids: school_filter_school_ids.length > 0 ? school_filter_school_ids.join() : ''
                },resp => {
                    if (resp.code == 1) {
                        this.getTableData();
                        this.showChooseSchool = !this.showChooseSchool;
                        this.$message({
                            type: 'success',
                            message: '设置成功',
                            center: true
                        });
                    } else {
                        this.$message({
                            type: 'warning',
                            message: resp.msg,
                            center: true
                        });
                    }
                });
            } else {
                this.multipleSelection.map(item => {
                    this.$post('/student/shop_goods%5Cset_school_filter',{
                        goods_no: item.goods_no,
                        school_filter_status: this.filter_status,
                        school_filter_school_ids: school_filter_school_ids.length > 0 ? school_filter_school_ids.join() : ''
                    },resp => {
                        if (resp.code == 1) {
                            this.getTableData();
                        } else {
                            this.indexError ++;

                        }
                    });
                });

                setTimeout(()=>{
                    if (this.indexError > 0) {
                        this.$message({
                            type: 'warning',
                            message: `设置失败${this.indexError}个`,
                            center: true
                        });
                    } else {
                        this.$message({
                            type: 'success',
                            message: '设置成功',
                            center: true
                        });
                    }
                    this.indexError = 0;
                    this.showChooseSchool = !this.showChooseSchool;
                },500);
            }
        },

        /**
         * 排序修改
         */
        fnEditSort(item, type) {
            this.$prompt('修改', '', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                inputPlaceholder: '请输入数字',
                inputErrorMessage: '请输入正整数',
                inputValue: item.course_sort_global,
                closeOnClickModal: false,
            }).then(({ value }) => {
                this.$post('/student/shop_goods%5Cmodify', {
                    goods_no: item.goods_no,
                    [type] : value
                }, resp => {
                    if (resp.code == 1) {
                        this.$notify({
                            type: 'success',
                            message: '修改成功',
                            title: '提示'
                        });
                        this.$set(item, type, value);
                    } else {
                        this.$notify({
                            type: 'warning',
                            message: resp.msg || '修改失败',
                            title: '提示'
                        });
                    }
                });
            });
        },

        /**
         * 上架/下架
         */
        fnSetStatus (row) {
            this.$post('/student/shop_goods%5Cset_status',{
                goods_no: row.goods_no,
                status: row.goods_status == 1 ? 1 : -1
            },resp => {
                if (resp.code == 1) {
                    this.$message({
                        type: 'success',
                        message: '设置成功'
                    });
                } else if (resp.code == 0) {
                    this.$message({
                        type: 'warning',
                        message: resp.msg
                    });
                }
            });
        },

        /**
         * 商品组分类
         */
        fnEditSortCate (item, type) {
            this.$prompt('修改', '', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                inputPlaceholder: '请输入数字',
                inputErrorMessage: '请输入正整数',
                inputValue: item.course_sort_global,
                closeOnClickModal: false,
            }).then(({ value }) => {
                this.$post('/student/shop_goods_cate_type%5Cset_goods_sort', {
                    goods_no: item.goods_no,
                    cate_type_no: this.$route.query.cate_type_no,
                    sort: value
                }, resp => {
                    if (resp.code == 1) {
                        this.$message({
                            type: 'success',
                            message: '修改成功'
                        });
                        this.$set(item, type, value);
                    } else {
                        this.$message({
                            type: 'warning',
                            message: resp.msg || '修改失败'
                        });
                    }
                });
            });
        },

        /**
         * 删除商品
         */
        fnDeleteGoods(item){
            this.$confirm('确认删除当前商品?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {
                this.$post('/student/shop_goods%5Cdelete', {
                    goods_no: item.goods_no
                }, resp => {
                    if (resp.code == 1) {
                        this.$message({
                            type: 'success',
                            message: '删除成功'
                        });
                        this.getTableData();
                    } else {
                        this.$message({
                            type: 'warning',
                            message: resp.msg || '删除失败'
                        });
                    }
                });
            });
        },

        /**
         * 审核
         * @param item
         * @param status
         * @returns {Promise<void>}
         */
        async fnAudit(item, status){
            let reason = 'eeee';

            try{
                await new Promise((resolve, reject) => {
                    if(status == -1){
                        this.$prompt('请输入不通过原因', '提示', {
                            confirmButtonText: '确定',
                            cancelButtonText: '取消',
                            inputPattern: /\S/,
                            inputErrorMessage: '请输入不通过原因'
                        }).then(({ value }) => {
                            reason = value;
                            resolve();
                        }).catch(() => {
                            reject();
                        });
                    }else{
                        resolve();
                    }
                });
                this.$post('/student/shop_goods%5Caudit', {
                    action: status == 1 ? 'pass' : 'fail',
                    goods_no: item.goods_no,
                    reason: reason
                }, resp => {
                    if (resp.code == 1) {
                        this.$set(item, 'audit_status', status);
                        this.$message({
                            type: 'success',
                            message: '操作成功'
                        });
                        this.getTableData();
                    } else {
                        this.$message({
                            type: 'warning',
                            message: resp.msg || '操作失败'
                        });
                    }
                });
            }catch(e){
                console.log('cancel');
            }
        },

        /**
         * 设置商品精选
         */
        fnSetCateRecommend (row, param) {
            this.$post('/student/shop_goods_cate%5Cset_goods_recommend',{
                cate_no: this.filterData.cate_no_type,
                goods_no: row.goods_no,
                type: param == 1 ? 1 : 2
            }, resp => {
                if (resp.code == 1) {

                    this.$set(row,'cate_recommend', param);
                    if(param == 1) {
                        this.$message({
                            type: 'success',
                            message: '已加入精选',
                            center: true
                        });
                    } else {
                        this.$message({
                            type: 'success',
                            message: '已取消精选',
                            center: true
                        });
                    }
                } else {
                    this.$message({
                        type: 'warning',
                        message: resp.msg,
                        center: true
                    });
                }
            });
        },

        /**
         * 编辑商品组
         */
        fnEditGroup (row) {
            this.$post('/student/shop_goods%5Ccurrent_cate', {
                goods_no: row.goods_no
            }, resp => {
                if (resp.code == 1) {
                    if(Object.prototype.toString.call(resp.data) !== '[object Null]' && resp.data.list.length > 0) {
                        this.$refs.shopGroup.getType('edit', {
                            data: resp.data,
                            goods_no: row.goods_no
                        });
                        this.$refs.shopGroup.show();
                    } else {
                        this.$message({
                            type: 'warning',
                            message: '该商品还没有设置商品组分类'
                        });
                        return false;
                    }
                } else {
                    this.$message({
                        type: 'warning',
                        message: resp.msg
                    });
                }
            });
        },

        /**
         * 移出商品组
         */
        fnRemoveGroup (row) {
            this.$confirm('是否将该商品移出该商品组及其以下所有的分类？', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {
                this.$post('/student/shop_goods%5Cquit_cate', {
                    goods_nos: row.goods_no,
                    data_nos: this.$route.query.sub_type_no
                }, resp => {
                    if (resp.code == 1) {
                        this.getTableData();
                        this.$message({
                            type: 'success',
                            message: '操作成功'
                        });
                    } else {
                        this.$message({
                            type: 'warning',
                            message: resp.msg
                        });
                    }
                });
            });
        },

        /**
         * 移除分类组
         */
        fnRemoveGroupChild (row) {
            this.$confirm('是否将该商品移出此商品组分类？', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {
                this.$post('/student/shop_goods%5Cquit_cate', {
                    goods_nos: row.goods_no,
                    data_nos: this.$route.query.cate_type_no
                }, resp => {
                    if (resp.code == 1) {
                        this.getTableData();
                        this.$message({
                            type: 'success',
                            message: '操作成功'
                        });
                    } else {
                        this.$message({
                            type: 'warning',
                            message: resp.msg
                        });
                    }
                });
            });
        },

        /**
         * 查看素材库
         * @param row
         */
        goMaterialList(row) {
            let routeData = this.$router.resolve({
                name: 'materialLibrary',
                query: {
                    goods_no: row.goods_no
                }
            });

            window.open(routeData.href, '_blank');
        },

        /**
         * 获取推荐到商品组数据
         */
        getData (resp) {
            // console.log(resp);
            // console.log(this.multipleSelection);
            if(resp.type == 'add') {
                let goods_no = this.multipleSelection.reduce((cur,next) => {
                    cur.push(next.goods_no);
                    return cur;
                },[]);

                this.$post('/student/shop_goods%5Cjoin_cate', {
                    goods_nos: goods_no.join(),
                    data_nos: resp.data.join()
                }, resp => {
                    if (resp.code == 1) {
                        this.$refs.shopGroup.hide();
                        this.getTableData();
                        this.$message({
                            type: 'success',
                            message: '操作成功'
                        });
                    } else {
                        this.$message({
                            type: 'warning',
                            message: resp.msg
                        });
                    }
                });
            }

            if(resp.type == 'edit') {
                this.$post('/student/shop_goods%5Cset_cate', {
                    goods_nos: resp.goods_no,
                    data_nos: resp.data.join()
                }, resp => {
                    if (resp.code == 1) {
                        this.$refs.shopGroup.hide();
                        this.getTableData();
                        this.$message({
                            type: 'success',
                            message: '编辑成功'
                        });
                    } else {
                        this.$message({
                            type: 'warning',
                            message: resp.msg
                        });
                    }
                });
            }
        },

        /**
         * 打标签
         */
        fnLabel (row) {
            this.$refs.setGoodsTags.show(row.goods_no);
        },

        /**
         * 每页条数更改
         * @param page_size
         */
        handleSizeChange(page_size) {
            this.page.page_size = page_size;
            this.getTableData();
        },
    }
};
</script>

<style scoped lang="less">
.wrapper {
    width: 100%;
    .content-wrapper {
        display: flex;
        height: calc(100% - 24px);
        flex-direction: column;
        position: relative;
        margin: 12px;
        background: #fff;
        box-sizing: border-box;

        /*header*/
        .header {
            height: 68px;
            padding: 24px;
            box-sizing: border-box;
            box-shadow: 0px -1px 0px 0px #F0F2F5;
            display: flex;
            align-items: center;
            justify-content: space-between;
            border-bottom: 1px solid #F0F2F5;

            .header-title {
                color: #333333;
                font-size: 20px;
                height: 20px;
                font-weight: 500;
                position: relative;
                margin: 24px 0 24px 12px;

                &::before {
                    content: '';
                    position: absolute;
                    left: -8px;
                    top: -1px;
                    width: 3px;
                    height: 20px;
                    background: #1890FF;
                }
            }
            .opt-btn-group {
                display: flex;
                .opt-btn-item {
                    padding: 0 24px;
                    height: 48px;
                    font-size: 14px;
                    font-family: PingFangSC-Medium, PingFang SC;
                    font-weight: 500;
                    color: #1890FF;
                    display: flex;
                    align-items: center;
                    justify-content: center;
                    cursor: pointer;
                    border-left: 1px solid #F0F2F5;
                    &:first-of-type {
                        border: 0;
                    }
                    &:hover {
                        background: #F9F9F9;
                        transition: all 0.2s;
                    }
                }
            }
        }

        /*筛选*/

        .filter-view {
            box-sizing: border-box;
            display: flex;
            align-items: center;
            flex-wrap: wrap;
            padding: 0 24px;
            margin-top: 12px;

            .header-new-box {
                display: flex;
                align-items: center;
                font-family: PingFangSC-Regular, PingFang SC;
                font-weight: 400;
                color: #333333;
                white-space: nowrap;
                margin-right: 24px;
                margin-bottom: 12px;

                &-title {
                    margin-right: 16px;
                    white-space: nowrap;
                }
                .query-btn {
                    width: 68px;
                    height: 36px;
                    background: #FFFFFF;
                    border-radius: 4px;
                    border: 1px solid #1890FF;
                    font-size: 14px;
                    font-family: PingFangSC-Medium, PingFang SC;
                    font-weight: 500;
                    color: #1890FF;
                    display: flex;
                    align-items: center;
                    justify-content: center;
                    cursor: pointer;
                }
            }
        }
        // 表格
        .table-wrapper {
            padding: 0 24px;
            flex: 1;
            height: 0;
            .goods-info {
                display: flex;
                align-items: center;
                .goods-cover {
                    width: 86px;
                    height: 86px;
                    cursor: pointer;
                    margin-right: 16px;
                }
                .info {
                    display: flex;
                    flex-direction: column;
                    justify-content: space-between;
                    font-size: 12px;
                    font-family: PingFangSC-Regular, PingFang SC;
                    font-weight: 400;
                    color: #333333;
                    .goods-info__title {
                        font-size: 14px;
                        cursor: pointer;
                        color: #409EFF;
                        display: -webkit-box;
                        -webkit-box-orient: vertical;
                        overflow: hidden;
                        -webkit-line-clamp: 2;
                    }
                }
            }

            .cursor-font {
                color: #409EFF !important;
                cursor: pointer;
            }
            .reduction_price {
                color: #FF3030;
                font-size: 14px;
                box-sizing: border-box;
                border: 1px #FF3030 solid;
                border-radius: 4px;
                padding: 7px 5px;
            }
        }

        // 表格
        .data-table {
            ::-webkit-scrollbar {
                width: 6px;
                height: 6px;
            }
            // 操作按钮
            .option-btn-group {
                .el-button {
                    margin-left: 0;
                    margin-right: 10px;
                }
                .btn-delete {
                    color: #fd4d32;
                    &.is-disabled {
                        color: #c0c4cc;
                        cursor: not-allowed;
                    }
                }
            }
        }

        /* 分页 */
        .pagination-wrapper {
            padding: 12px 24px;
            .el-pagination {
                float: right;
                padding: 0;
                background-color: transparent;
            }
        }
    }

    .el-tag-school {
        display: flex;
        width: 100%;
        flex-wrap: wrap;
        margin-bottom: 10px;
        .el-tag{
            margin-right: 10px;
            margin-bottom: 10px;
            height: 32px;
            display: flex;
            align-items: center;
        }
    }
    .el-school-filter {
        display: flex;
        height: 32px;
        align-items: center;
        margin-top: 15px;
    }
    .task-review-status {
        .status {
            position: relative;
            display: inline-block;
            padding-left: 9px;
            &::before {
                content: "";
                position: absolute;
                top: 50%;
                left: 0;
                transform: translate(0, -50%);
                width: 6px;
                height: 6px;
                border-radius: 50%;
            }
            &.wait-submit,
            &.wait-audit {
                &::before {
                    background-color: #f5a623;
                }
            }
            &.deny {
                &::before {
                    background-color: #ff0019;
                }
            }
            &.completed {
                &::before {
                    background-color: #00c800;
                }
            }
        }
    }

    /deep/ .el-dialog__header {
        padding-top: 10px;
        box-shadow: 0 1px 0 0 rgba(233, 233, 233, 1);
        display: flex;
        align-items: center;
        background: #FAFAFA;
        border-radius: 4px 4px 0 0;

        .el-dialog__title {
            font-weight: 500;
            color: #333;
            font-size: 14px;
        }

        .el-icon-close:before {
            color: rgb(194, 194, 194);
            font-size: 17px;
            font-weight: bold;
        }

        .el-dialog__headerbtn {
            top: 14px;
        }
    }

    /deep/ .el-textarea__inner {
        resize: none;
    }

    /deep/ .el-radio-button {
        &.is-active {
            .el-radio-button__inner {
                background: #E6F1FC;
                color: #20A0FF;
                border-color: #20A0FF;
            }
        }
    }
    /deep/ .el-table__fixed-right {
        right: 6px!important;
    }
}
.shopAdd_result .el-dialog .el-dialog__body {
    max-height: 650px !important;
    overflow-y: auto;
    &::-webkit-scrollbar{
        width: 3px;
    }
    .shop_addInfo_sucess {
        color: #409EFF;
    }
    .shop_addInfo_error {
        color: #fd4d32;
    }
}
</style>

<style lang="less">
.school-list {
    .el-checkbox-button {
        margin-right: 10px;
        margin-bottom: 10px;
        border-radius: 0;
    }
    .el-checkbox-button:first-child .el-checkbox-button__inner {
        border-radius: 2px;
    }
    .el-checkbox-button__inner {
        border-left: 1px solid #dcdfe6;
        font-size: 12px;
        font-weight: 400;
        color: rgba(126, 137, 147, 1);
        border-radius: 2px;
        position: relative;
    }
    .el-checkbox-button.is-checked .el-checkbox-button__inner {
        background-color: #fff;
        border: 1px solid rgba(32, 160, 255, 1);
        color: #20a0ff;
        box-shadow: none;
        overflow: hidden;
        &::after {
            content: " ";
            position: absolute;
            bottom: 0;
            right: 0;
            width: 24px;
            height: 18px;
            background-image: url(//cdn.zsdx.cn/admin/images/common/checked.png);
            background-position: center;
            background-size: cover;
            background-repeat: no-repeat;
        }
    }
}
</style>
